package com.egao.orderB.service.impl;

import com.egao.common.core.damon.utils.DateUtil;
import com.egao.orderB.biz.SequenceBiz;
import com.egao.orderB.service.SequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 *
 * 数据服务层接口实现类
 * @author : Doman
 * @date : 2019-08-17 15:38:50
 * @version ：1.0
 */
@Service
public class SequenceServiceImpl implements SequenceService {

	@Autowired
	private SequenceBiz sequenceBiz;

	@Override
	public String genCertCode(String prefix, String companyId) {
//		String separator = "-";
		String separator = "";
		String datePart = DateUtil.formatDate(new Date(),"yyyyMMdd");

		StringBuffer sb = new StringBuffer();

		sb.append(prefix).append(separator).append(datePart).append(separator);

		String counterPart = sequenceBiz.getSequence(prefix, companyId);
		System.out.println("sequence code:"+sb.append(counterPart));
		return sb.toString();
	}
}
